package CodeOne;

import java.util.Scanner;

/** @author ASUS */
public class Calculations {
  public static void main(String[] args) {
    String input;
    Scanner inputScanner = new Scanner(System.in);
    while (inputScanner.hasNextLine()) {
      input = inputScanner.nextLine();
      String[] tempDate = input.split(" ");
      int tempYear = Integer.parseInt(tempDate[0]);
      int tempDays = Integer.parseInt(tempDate[1]);
      /* System.out.printf("%d-%d\t", tempYear, tempDays); */
      int[] monthsNormal = new int[] {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365};
      int[] monthsLeap = new int[] {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 365};
      boolean isLeapYear = false;
      if (tempYear % 400 == 0) {
        isLeapYear = true;
      } else if (tempYear % 4 == 0 && tempYear % 400 != 0) {
        isLeapYear = true;
      }
      int month = 0, days = 0;
      if (isLeapYear) {
        for (int i = 0; i < monthsLeap.length - 1; i++) {
          if ((tempDays > monthsLeap[i]) && (tempDays <= monthsLeap[i + 1])) {
            month = i + 1;
            days = tempDays - monthsLeap[i];
            break;
          }
        }
      } else {
        for (int i = 0; i < monthsNormal.length - 1; i++) {
          if ((tempDays > monthsNormal[i]) && (tempDays <= monthsNormal[i + 1])) {
            month = i + 1;
            days = tempDays - monthsNormal[i];
            break;
          }
        }
      }
      System.out.printf("%d-%02d-%02d\n", tempYear, month, days);
    }
  }
}
